<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <t:datagrid name="cbsCgreportHeadList" checkbox="true" fitColumns="false" title="自定义报表"
                    actionUrl="cbsCgreportHeadController.do?datagrid" idField="id" fit="true" queryMode="group">
            <t:dgCol title="id" field="id" hidden="true" queryMode="group" width="120"></t:dgCol>
            <t:dgCol title="isdel" field="isdel" hidden="true"></t:dgCol>
            <t:dgCol field="name" title="报表名称" query="true" queryMode="single" width="120"></t:dgCol>
            <t:dgCol field="property" title="报表属性" queryMode="single" replace="共享报表_1,用户报表_0" width="120"></t:dgCol>
            <t:dgCol field="content" title="说明" queryMode="group" width="120"></t:dgCol>
            <t:dgCol field="createBy" title="创建人" queryMode="group" width="120"></t:dgCol>
            <t:dgCol field="createDate" title="创建时间" formatter="yyyy-MM-dd" queryMode="group" width="120"></t:dgCol>
            <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
            <t:dgDelOpt title="删除" url="cbsCgreportHeadController.do?doDel&id={id}" exp="isdel#eq#1"/>
            <t:dgToolBar title="新建" icon="icon-add" url="cbsCgreportHeadController.do?goAdd" funname="addfun"></t:dgToolBar>
            <t:dgToolBar title="编辑" icon="icon-edit" funname="update"></t:dgToolBar>
            <t:dgToolBar title="执行" icon="icon-redo" funname="run"></t:dgToolBar>
        </t:datagrid>
    </div>
</div>
<script src="webpage/com/zybk/cbscgreportHead/cbsCgreportHeadList.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //给时间控件加上样式
        $("#cbsCgreportHeadListtb").find("input[name='createDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsCgreportHeadListtb").find("input[name='createDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
    });

    /**
     * 新建
     **/
    function addfun(filedName, url) {
        addOneTab("新建自定义报表", url);
    }

    /**
     * 编辑
     * */
    function update() {
        var datas = $("#cbsCgreportHeadList").datagrid("getSelections");
        if (datas.length != 1) {
            tip("请选择一条数据");
            return;
        }
        var id = datas[0].id;
        $.ajax({
            url: "cbsCgreportHeadController.do?getResultByid",
            data: {"id": id},
            cache: false,
            traditional: true,
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                if (!data.success) {
                    tip("没有编辑权限");
                } else {
                    addOneTab("编辑自定义报表", "cbsCgreportHeadController.do?goUpdate&id=" + id);
                }
            }
        });
    }

    /**
     * 执行
     */
    function run() {
        var datas = $("#cbsCgreportHeadList").datagrid("getSelections");
        if (datas.length != 1) {
            tip("请选择一条数据");
            return;
        }
        var id = datas[0].id;
        addOneTab("执行结果", "cbsCgreportHeadController.do?showSqlView&id=" + id);
    }

    //导入
    function ImportXls() {
        openuploadwin('Excel导入', 'cbsCgreportHeadController.do?upload', "cbsCgreportHeadList");
    }

    //导出
    function ExportXls() {
        JeecgExcelExport("cbsCgreportHeadController.do?exportXls", "cbsCgreportHeadList");
    }

    //模板下载
    function ExportXlsByT() {
        JeecgExcelExport("cbsCgreportHeadController.do?exportXlsByT", "cbsCgreportHeadList");
    }
</script>